<?php
$this->Html->addCrumb('Ads', '/admin/ads');
$this->Html->addCrumb('Photos');
$this->Html->addCrumb('Edit');

$this->Html->scriptStart(array('inline' => false));
echo '
      $(function(){      
         $("#deleteBtn").click(function(event){
          if(!$("#deleteBtn").attr("data-delete-confirm")) {
          $("#deleteBtn").attr("data-delete-confirm","");
            $.TWS_Overlay("confirm", {title : "Delete confirmation", message : "Are you sure you want to delete this record?", buttons : {ok :{onclick : function () { $.TWS_Overlay("hide"); $("#deleteBtn").attr("data-delete-confirm",true).trigger("click");}}}});
            event.preventDefault();
          }
        });

        $("#AdPhotoAdminEditForm").TWS_Form( {
          validate : {
          rules : {
            AdPhotoTitle : {required : true, help : "Select a title to describe the photo"},
            AdPhotoDescription : {help : "This is the text that will accompany the ad."}
          }
          }});


     });
       ';
$this->Html->scriptEnd();

?>


<h1>Edit Ad Photo</h1>
<p>
<span class="info">Company</span> : <?php echo $this->viewVars['groupInfo']['Company']['name'];?> <br/>
<span class="info">Ad</span> : <?php echo $this->viewVars['groupInfo']['Ad']['description'];?>
</p>
<?php echo '<div id="actionLink">'.$this->Html->link('Back to list of Photos',array('action'=>'index','admin'=>true, $adId)).'</div>'; ?>

<?php echo $this->element('errors', array('errors' => isset($errors)? $errors : null));

echo $this->TWSForm->create('AdPhoto',  array(
    'inputDefaults' => array(
        'div' => array('class'=>'row')),
        'class'=>'inlineForm',
        'type'=>'file'));
$record = $this->request->data['AdPhoto'];
echo $this->TWSForm->input('ad_id', array('type'=>'hidden', 'name'=>'AdPhotoAdId', 'value'=>$adId));
echo $this->TWSForm->input('title', array('rows'=>'5','cols'=>'60','name'=>'AdPhotoTitle', 'label'=>'<span class="required">*</span>Title'));
echo $this->TWSForm->input('description', array('rows'=>'5','cols'=>'60','name'=>'AdPhotoDescription', 'label'=>'Description'));
echo '<p>'.$this->Html->image($record['image_path'], array('alt' => $record['title'], 'class'=>'photo')).'</p>';
echo $this->TWSForm->submit('Update', array('id'=>'editBtn', 'name'=>'editBtn', 'class'=>'button', 'div'=>false));
echo $this->TWSForm->submit("Delete", array('id'=>'deleteBtn','name'=>'deleteBtn', 'class'=>'button', 'div'=>false));
echo $this->TWSForm->end();

?>